<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$ci = &get_instance();
	$USER = $ci->user_entity->init('id',$ESCORT->getUserId());
	$geoArray = explode('#', $ESCORT->getGeolocation());
	$lat = count($geoArray)==2 ? $geoArray[0] :'0';
	$lng = count($geoArray)==2 ? $geoArray[1] :'0';
?>

<?php if( $ESCORT->getPublicPhone() == 1 ): ?>
	<div class="escort-infor-item-wrapper">
		<div class="escort-infor-item-left">
			<span><?php echo language_translate('contact_info_phone');?></span>
		</div>
		<div class="escort-infor-item-right">
			<span>
				<img src="<?php echo createImageText($ESCORT->getEscortPhone(),'phone_'.$ESCORT->getId());?>" />
			</span>
		</div>
		<div class="clear"></div>
	</div>
<?php endif; ?>

<?php if( $ESCORT->getPublicEmail() == 1 ): ?>
	<div class="escort-infor-item-wrapper">
		<div class="escort-infor-item-left">
			<span><?php echo language_translate('contact_info_email');?></span>
		</div>
		<div class="escort-infor-item-right">
			<span>
				<img src="<?php echo createImageText($ESCORT->getEscortEmail(),'email_'.$ESCORT->getId());?>" />
			</span>
		</div>
		<div class="clear"></div>
	</div>
<?php endif; ?>

<?php if( $ESCORT->getPublicAddress() == 1 ): ?>
	<div class="escort-infor-item-wrapper">
		<div class="escort-infor-item-left">
			<span><?php echo language_translate('contact_info_address');?></span>
		</div>
		<div class="escort-infor-item-right">
			<span>
				<?php echo $ESCORT->getEscortAddress();?> 
			</span>
		</div>
		<div class="clear"></div>
	</div>	
<?php endif; ?>


<div class="escort-infor-item-wrapper">
	<?php if($ESCORT->getPublicGeolocation()):?>
		<div id="map_canvas" style="width:350px;margin-top:20px;"></div> 
		<div class="clear"></div>
	<?php endif; ?>	
</div>
 
<script type="text/javascript">
	var displayMap = '<?php echo $ESCORT->getShowAddressOnMap();?>';
	var address = '<?php echo $USER->getAddress();?>';
	var isGMAPShow = '<?php echo ($ESCORT->getPublicGeolocation() == 1) ? $ESCORT->getPublicGeolocation() :0;?>';
	
	$(document).ready(function() {	
		$('#contact-info').height(385);
		$('#map_canvas').height(241);
		 
		if(isGMAPShow == '1'){
			showMap(<?php echo $lat ;?>,<?php echo $lng ;?>);
		}
		
		$( "#accordion" ).bind( "accordionchange", function(event, ui) {
		   if(isGMAPShow == '1'){
				showMap(<?php echo $lat ;?>,<?php echo $lng ;?>);
			}
		});
	});	
	
//	google.setOnLoadCallback(function() {
//		
//	});
 
	function showMap(lat , lng){
		//geocoder = new google.maps.Geocoder();
		var latlng = new google.maps.LatLng(lat,lng);
		var myOptions = {
		  zoom: 14,
		  center: latlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
		marker = new google.maps.Marker({
		  position: latlng,
		  map: map
		});
		
		var contentString = '<div id="overlay-window-info">'+address+'</div>';
		var infowindow = new google.maps.InfoWindow({
			content: contentString
		});

		if(displayMap){
			google.maps.event.addListener(marker, 'click', function() {
				infowindow.open(map,marker);
			});
		}		
	}
</script>






